package com.yang.job.core.dto;

import java.io.Serializable;

public class ResultT <T> implements Serializable {
    private Integer code;

    private String msg;

    private T data;

    private ResultT(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private ResultT(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }


    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }

    public static <T> ResultT<T> success() {
        return new ResultT<>(200, "操作成功");
    }

    public static <T> ResultT<T> success(T data) {
        return new ResultT<>(200, "操作成功", data);
    }

    public static <T> ResultT<T> fail() {
        return new ResultT<>(400, "操作失败");
    }

    public static <T> ResultT<T> fail(String msg) {
        return new ResultT<>(400, msg);
    }


}
